package Model;

import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

public class CarList {

	public  ArrayList<Car> CarList = new ArrayList<Car>();
	
	private DbConnection db = null;
	private Statement st = null;
	private ResultSet rs = null; 
	
	public CarList(){
		   db = new DbConnection();	   
		   st = db.getStatement();
		   
		   try{
				this.rs = this.st.executeQuery("Select id_car,model from car order by model asc;");
				
				Car car = new Car();
				
				while(this.rs.next()){
					car.setCar(this.rs.getInt("id_car"));
					this.CarList.add(car);
				}
				
			}catch (Exception e) {
				System.out.print(e.toString());
			}   
		
	}
	
}
